package gestoreImmagini;

import android.content.Context;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView;

import com.example.helloImageDetection.R;

public class ListaLoghiCursorAdapter extends SimpleCursorAdapter{
	
	
	public ListaLoghiCursorAdapter (Context context, int layout, Cursor c, String[] from, int[] to) {
		super(context, layout, c, from, to);
	}


	@Override
	public View newView(Context context, Cursor cursor, ViewGroup parent) {	
		LayoutInflater inflater = LayoutInflater.from(context);
		View v = inflater.inflate(R.layout.riga_logo, parent, false);
		bindView(v, context, cursor);
		return v;
	}
		
		 
		
	@Override
	public void bindView(View v, Context context, Cursor c) {
		TextView nome = (TextView)v.findViewById(R.id.riga_logo_nome);
		nome.setText(c.getString(c.getColumnIndex("nome")));
		
		TextView descrizione = (TextView)v.findViewById(R.id.riga_logo_descrizione);
		descrizione.setText(c.getString(c.getColumnIndex("descrizione")));

		ImageView logo = (ImageView)v.findViewById(R.id.riga_logo_logo);
		Bitmap bm = MyDbConnector.byteArrayToBitmap(c.getBlob(c.getColumnIndex("logo")));
		logo.setImageBitmap(bm);		
	}

}
